#ifndef _DevicesSoftIIC_H_
#define _DevicesSoftIIC_H_

#define SORT_IIC_ACK    0
#define SORT_IIC_NACK   1
#define SORT_IIC_BUSY   2
#define SORT_IIC_NORMAL 3

#define SORT_IIC_WRITE_MODE 0x00
#define SORT_IIC_READ_MODE  0x01


typedef struct SoftIICStruct{
    GPIO_TypeDef * SclGPIO;
    GPIO_TypeDef * SdaGPIO;

    uint16_t SclPin;
    uint16_t SdaPin;

    void (* GPIOSetMode) (struct SoftIICStruct *pHandle, uint32_t typeMode);

    void (* GPIOSetHigh) (GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
    void (* GPIOSetLow) (GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);

    uint8_t (* GPIOReadBit) (GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);

    float delayTime;
}SoftIICHandle;


#define SOFT_IIC_RT8092_VCC2_SCK_RCC_GPIO_CLK_ENABLE()              __HAL_RCC_GPIOB_CLK_ENABLE()
#define SOFT_IIC_RT8092_VCC2_SCK_GPIO_Port                          GPIOB
#define SOFT_IIC_RT8092_VCC2_SCK_Pin                                GPIO_PIN_5

#define SOFT_IIC_RT8092_VCC2_SDA_RCC_GPIO_CLK_ENABLE()              __HAL_RCC_GPIOB_CLK_ENABLE()
#define SOFT_IIC_RT8092_VCC2_SDA_GPIO_Port                          GPIOB
#define SOFT_IIC_RT8092_VCC2_SDA_Pin                                GPIO_PIN_6

#define SOFT_IIC_RT8092_VCC2_DELAY_BIT_TIME 1.5f




extern SoftIICHandle ex_SoftIICRT8092VCC2Handle;




void vSoftIICxSetSdaGPIOMode(SoftIICHandle *pHandle, uint32_t typeMode);
int8_t cSoftIICxWriteDatas(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t *pucDatas, uint32_t iLength);
int8_t cSoftIICxWriteByte(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t ucByte);
int8_t cSoftIICxReadDatas(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t *pucDatas, int32_t iLength);
int8_t cSoftIICxReadByte(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t *pucByte);

void vSoftIICRT8092VCC2Init(void);
#define cSoftIICRT8092VCC2WriteDatas(ucAddr, ucReg, pucDatas, iLength)  cSoftIICxWriteDatas(&ex_SoftIICRT8092VCC2Handle, ucAddr, ucReg, pucDatas, iLength)
#define cSoftIICRT8092VCC2WriteByte(ucAddr, ucReg, ucByte)              cSoftIICxWriteByte(&ex_SoftIICRT8092VCC2Handle, ucAddr, ucReg, ucByte)
#define cSoftIICRT8092VCC2ReadDatas(ucAddr, ucReg, pucDatas, iLength)   cSoftIICxReadDatas(&ex_SoftIICRT8092VCC2Handle, ucAddr, ucReg, pucDatas, iLength)
#define cSoftIICRT8092VCC2ReadByte(ucAddr, ucReg, pucByte)              cSoftIICxReadByte(&ex_SoftIICRT8092VCC2Handle, ucAddr, ucReg, pucByte)



#endif
